Ext.onReady(function(){
    var eventStore = Ext.create('Extensible.calendar.data.EventStore', {
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: '/resourcecontrol/schedule_list/',
            actionMethods:'post',
            noCache: false,
            reader: {
                type: 'json',
                root: 'rows'
            }
        }
	});
	

	
    var ScheduleCalendar=Ext.create('Extensible.calendar.CalendarPanel', {
    	goText:'查询',
    	jumpToText:'时间',
        eventStore: eventStore,
        showMultiWeekView: false,
        listeners: {
        	'eventadd':function(me,rec){
    			Ext.Ajax.request({
    			    url:'/resourcecontrol/schedule_save/',
    			    method : 'post',
    			    params:{
    			    	title:rec.data.Title,
    			    	notes:rec.data.Notes,
    			    	start:rec.data.StartDate,
    			    	end:rec.data.EndDate,
    			    	ad:rec.data.IsAllDay,
    			    	loc:rec.data.Location,
    			    	rem:rec.data.Reminder,
    			    	url:rec.data.Url
    			    },
    			    success:function(response){
    			        var results =  Ext.decode(response.responseText);
    			        if(results.success){
    			        	
    			        }else{
    			        	Ext.Msg.alert('系统提示', results.message);
    			        }
    			    }
    			});        		
        	},
        	'eventupdate':function(me,rec){
    			Ext.Ajax.request({
    			    url:'/resourcecontrol/schedule_save/',
    			    method : 'post',
    			    params:{
    			    	id:rec.data.EventId,
    			    	title:rec.data.Title,
    			    	notes:rec.data.Notes,
    			    	start:rec.data.StartDate,
    			    	end:rec.data.EndDate,
    			    	ad:rec.data.IsAllDay,
    			    	loc:rec.data.Location,
    			    	rem:rec.data.Reminder,
    			    	url:rec.data.Url
    			    },
    			    success:function(response){
    			        var results =  Ext.decode(response.responseText);
    			        if(results.success){
    			        	
    			        }else{
    			        	Ext.Msg.alert('系统提示', results.message);
    			        }
    			    }
    			});
        	},
        	'eventdelete':function(me,rec){
    			Ext.Ajax.request({
    			    url:'/resourcecontrol/schedule_del/',
    			    method : 'post',
    			    params:{
    			    	id:rec.data.EventId
    			    },
    			    success:function(response){
    			        var results =  Ext.decode(response.responseText);
    			        if(results.success){
    			        	
    			        }else{
    			        	Ext.Msg.alert('系统提示', results.message);
    			        }
    			    }
    			});
        	}        	
        }
    });
    
    Ext.apply(Extensible.form.field.DateRange.prototype, {
        dateFormat: 'Y-n-j',
        timeFormat: 'G:i'
    });
    
    
    
	Ext.create('Ext.container.Viewport',{
		layout:'fit',
		renderTo: 'schedule-panel',
		items:[ScheduleCalendar]
	});	    
});
